package dse;

public class StringUtil {
	private StringUtil () {/**/}
	
	public static String timeString (double time) {
		// Assume time is in seconds
		double hours = Math.floor(time/3600);
		double minutes = Math.floor((time - hours*3600)/60);
		double seconds = time - hours*3600 - minutes*60;
		
		return String.format(
				"%02.0f:%02.0f:%09.6f", 
				new Object [] {hours, minutes, seconds}
				);
	}
	
	public static String byteString (double bytes) {
		if (bytes > 1000000000)
			return String.format("%.2fGB", bytes/1000000000);
		else if (bytes > 1000000)
			return String.format("%.2fMB", bytes/1000000);
		else if (bytes > 1000)
			return String.format("%.2fKB", bytes/1000);
		return String.format("%.2fB", bytes);
	}
	
	public static String distanceString (double distance) {
		return String.format("%.2f miles", distance);
	}
}
